﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Netfraction.RemoteMachine
{
    public class PeerEventArgs : EventArgs
    {
        public PeerEventArgs(Peer peer)
        {
            this.Peer = peer;
        }

        public RemoteMachine.Peer Peer { get; set; }
    }

    public class Peer : Node
    {
        public Peer()
        {
            InitialiseFeatures();

            mConnection = new PeerConnection(this);
        }

        private void InitialiseFeatures()
        {
            LocalMachine.Client cli = LocalMachine.Client.GetInstance();

            lock (cli)
            {
                string baseProtocolName = Network.Protocol.ProtocolFeature.GetFeatureName(typeof(Network.Protocol.BASE.ProtocolFeatureBASE));
                this.Features.Add(baseProtocolName, cli.Features[baseProtocolName]);
                // should be adding TIGR etc here... or should we... wtf is going on here? Isn't the SUP handler meant to do this when you connect to a peer?
            }
        }

        public bool IsLocalClient { get; set; }
        public bool IsOnline { get; set; }

        public override Connection Connection
        {
            get
            {
                return mConnection as PeerConnection;
            }
            set
            {
                mConnection = value;
            }
        }
    }
}
